import requests
import os

headers = {
    'Accept': ',application/json, text/plain, */*',  # 请求头信息
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Connection': 'keep-alive',
    'Cookie': '_ga=GA1.2.1637941648.1616934252; uname3=qq1616934321; t3kwid=131286315; websid=1488073791; pic3=""; t3=qq; Hm_lvt_cdb524f42f0ce19b169a8071123a4797=1617949101,1618127723,1618579672,1619099581; _gid=GA1.2.1505163314.1619099581; Hm_lpvt_cdb524f42f0ce19b169a8071123a4797=1619100738; _gat=1; kw_token=XM5GXCP8M5',
    'csrf': 'XM5GXCP8M5',
    'Host': 'www.kuwo.cn',
    'Referer': 'http://www.kuwo.cn/search/list?key=%E5%91%A8%E6%9D%B0%E4%BC%A6',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3861.400 QQBrowser/10.7.4313.400'
}


def main():
    # name=input('请输入要搜索的歌手名：')

    response = requests.get(
        url='http://www.kuwo.cn/api/www/search/searchMusicBykeyWord?key=%E5%91%A8%E6%9D%B0%E4%BC%A6&pn=1&rn=30&httpsStatus=1&reqId=883d74b0-3096-11ed-a768-43311753b43b',
        headers=headers)
    res=response.json()
    data=res['data']
    list=data['list']
    with open('../杂项/text.json', 'w') as f:
        f.write(data)


if __name__ == '__main__':
    main()

# http://www.kuwo.cn/api/v1/www/music/playUrl?mid=81933656&type=music&httpsStatus=1&reqId=18ddc921-3092-11ed-af0d-19d84d050ab3
# http://www.kuwo.cn/api/v1/www/music/playUrl?mid=81933656&type=music&httpsStatus=1&reqId=99074671-3093-11ed-9537-c1a424fdf14e
